package com.doubao.auth.client;

import com.doubao.auth.dto.WxLoginRequest;
import com.doubao.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 微信服务Feign客户端
 * 使用完整URL替代服务名称发现
 */
@FeignClient(
        name = "wechat-client",
        url = "${feign.wechat-service.url}"
)
public interface WechatClient {

    /**
     * 微信小程序登录
     *
     * @param request 登录请求
     * @return 微信用户信息
     */
    @PostMapping("/wechat/miniapp/login")
    Result<Map<String, Object>> miniappLogin(@RequestBody WxLoginRequest request);

    /**
     * 获取微信session key
     */
    @GetMapping("/wechat/session-key")
    Result<Map<String, Object>> getSessionKey(@RequestParam("code") String code);

    /**
     * 根据ID获取微信用户
     *
     * @param userId 用户ID
     * @return 微信用户信息
     */
    @GetMapping("/wechat/user/{userId}")
    Result<Map<String, Object>> getWechatUserByUserId(@PathVariable("userId") Long userId);

    /**
     * 绑定微信账号和用户
     */
    @PostMapping("/wechat/bind/{wechatUserId}/{userId}")
    Result<Void> bindUser(
            @PathVariable("wechatUserId") Long wechatUserId,
            @PathVariable("userId") Long userId);

    /**
     * 解绑微信账号
     */
    @PostMapping("/wechat/unbind/{userId}")
    Result<Void> unbindUser(@PathVariable("userId") Long userId);
}